#!/bin/bash
string1="1ABcd1234567"
string2="1234abcd567"

if [[ "$string1" =~ ^[a-zA-Z]{4}[0-9]{7}$ ]]; then
  echo "string1 ok"
else
  echo "string1 fail"
fi

if [[ "$string2" =~ ^[a-zA-Z]{4}[0-9]{7}$ ]]; then
  echo "string2 ok"
else
  echo "string2 fail"
fi
